using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace Scroll
{    
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;

        ScrollScene scrollScene;
        ScrollTile scrollTile;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }
                
        protected override void Initialize()
        {
            graphics.PreferredBackBufferWidth = 640;
            graphics.PreferredBackBufferHeight = 400;
            graphics.ApplyChanges();
            IsMouseVisible = true;
          // Components.Add(new ScrollTile(Content.Load<Texture2D>("nuvem"), new Point(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight), 10, 0.02f, this));
            base.Initialize();
        }

       
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            scrollScene = new ScrollScene(Content.Load<Texture2D>("imagem01"), Content.Load<Texture2D>("imagem02"), new Point(0, 400), this);//?
            scrollTile = new ScrollTile(Content.Load<Texture2D>("nuvem"), new Point(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight), 10, 0.02f, this);

            Services.AddService(typeof(SpriteBatch), spriteBatch);
        }

        protected override void UnloadContent()
        {
            
        }

        protected override void Update(GameTime gameTime)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
                this.Exit();

            scrollScene.Update(gameTime);
            //scrollTile.Update(gameTime);
            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);
            scrollScene.Draw(gameTime, spriteBatch);
           // scrollTile.Draw(gameTime);
            spriteBatch.End();

            base.Draw(gameTime);
        }
    }
}
